home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / thinkref / archive / THINKPascalUH2.1.sea / THINKPas Univ Hdr 2.1 / Interfaces / SoundComponents.p < prev    next >
Text File  |  1995-09-12  |  14KB  |  357 lines

  1. { Converted with MPW2TPas Tuesday, September 12, 1995 10:17:58 PM }
  2. {
  3.      File:        SoundComponents.p
  4.  
  5.      Contains:    Sound Components Interfaces.
  6.  
  7.      Version:    Technology:    System 7.5
  8.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  14.                  stack.  Include the file and version information (from above)
  15.                  in the problem description and send to:
  16.                      Internet:    apple.bugs@applelink.apple.com
  17.                      AppleLink:    APPLE.BUGS
  18.  
  19. }
  20.  
  21.  UNIT SoundComponents;
  22.  INTERFACE
  23.  
  24.  
  25. {$IFC UNDEFINED __SOUNDCOMPONENTS__}
  26. {$SETC __SOUNDCOMPONENTS__ := 1}
  27.  
  28.   USES
  29.    ConditionalMacros, Types, Components, Sound;
  30.  
  31. { $PUSH}
  32. { $ALIGN MAC68K}
  33. { $LibExport+}
  34. {
  35.                         * * *  N O T E  * * *
  36.  
  37.     This file has been updated to include Sound Manager 3.1 interfaces.
  38.  
  39.     Some of the Sound Manager 3.0 interfaces were not put into the InterfaceLib
  40.     that originally shipped with the PowerMacs. These missing functions and the
  41.     new 3.1 interfaces have been released in the SoundLib library for PowerPC
  42.     developers to link with. The runtime library for these functions are
  43.     installed by Sound Manager 3.1. The following functions are found in SoundLib.
  44.  
  45.         AudioGetBass, AudioGetInfo, AudioGetMute, AudioGetOutputDevice,
  46.         AudioGetTreble, AudioGetVolume, AudioMuteOnEvent, AudioSetBass,
  47.         AudioSetMute, AudioSetToDefaults, AudioSetTreble, AudioSetVolume,
  48.         OpenMixerSoundComponent, CloseMixerSoundComponent, SoundComponentAddSource,
  49.         SoundComponentGetInfo, SoundComponentGetSource, SoundComponentGetSourceData,
  50.         SoundComponentInitOutputDevice, SoundComponentPauseSource,
  51.         SoundComponentPlaySourceBuffer, SoundComponentRemoveSource,
  52.         SoundComponentSetInfo, SoundComponentSetOutput, SoundComponentSetSource,
  53.         SoundComponentStartSource, SoundComponentStopSource
  54. }
  55. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  56. { constants}
  57. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  58.  
  59. CONST
  60. {sound component set/get info selectors}
  61.     siVolume                    = 'volu';
  62.     siHardwareVolume            = 'hvol';
  63.     siSpeakerVolume                = 'svol';
  64.     siHeadphoneVolume            = 'pvol';
  65.     siHardwareVolumeSteps        = 'hstp';
  66.     siHeadphoneVolumeSteps        = 'hdst';
  67.     siHardwareMute                = 'hmut';
  68.     siSpeakerMute                = 'smut';
  69.     siHeadphoneMute                = 'pmut';
  70.     siRateMultiplier            = 'rmul';
  71.     siQuality                    = 'qual';
  72. {format types}
  73.     kOffsetBinary                = 'raw ';
  74.     kTwosComplement                = 'twos';
  75.     kMACE3Compression            = 'MAC3';
  76.     kMACE6Compression            = 'MAC6';
  77.  
  78. {quality flags}
  79. {use interpolation in rate conversion}
  80.     kBestQuality                = $1;
  81.  
  82. {useful bit masks}
  83.     kInputMask                    = $000000FF;                    {masks off input bits}
  84.     kOutputMask                    = $0000FF00;                    {masks off output bits}
  85.     kOutputShift                = 8;                            {amount output bits are shifted}
  86.     kActionMask                    = $00FF0000;                    {masks off action bits}
  87.     kSoundComponentBits            = $00FFFFFF;
  88.  
  89. {SoundComponentPlaySourceBuffer action flags}
  90.     kSourcePaused                = $1;
  91.     kPassThrough                = $10000;
  92.     kNoSoundComponentChain        = $20000;
  93. {flags for OpenMixerSoundComponent}
  94.     kNoMixing                    = $1;                {don't mix source}
  95.     kNoSampleRateConversion        = $2;                {don't convert sample rate (i.e. 11 kHz -> 22 kHz)}
  96.     kNoSampleSizeConversion        = $4;                {don't convert sample size (i.e. 16 -> 8)}
  97.     kNoSampleFormatConversion    = $8;                {don't convert sample format (i.e. 'twos' -> 'raw ')}
  98.     kNoChannelConversion        = $10;                {don't convert stereo/mono}
  99.     kNoDecompression            = $20;                {don't decompress (i.e. 'MAC3' -> 'raw ')}
  100.     kNoVolumeConversion            = $40;                {don't apply volume}
  101.     kNoRealtimeProcessing        = $80;                {won't run at interrupt time}
  102.  
  103. {Audio Component constants}
  104. {Values for whichChannel parameter}
  105.     audioAllChannels            = 0;                            {All channels (usually interpreted as both left and right)}
  106.     audioLeftChannel            = 1;                            {Left channel}
  107.     audioRightChannel            = 2;                            {Right channel}
  108. {Values for mute parameter}
  109.     audioUnmuted                = 0;                            {Device is unmuted}
  110.     audioMuted                    = 1;                            {Device is muted}
  111. {Capabilities flags definitions}
  112.     audioDoesMono                = $1;                {Device supports mono output}
  113.     audioDoesStereo                = $2;                {Device supports stereo output}
  114.     audioDoesIndependentChannels = $4;            {Device supports independent software control of each channel}
  115.  
  116. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  117. { typedefs}
  118. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  119. {ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,}
  120. {with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375}
  121.     
  122. TYPE
  123.     ShortFixed = INTEGER;
  124.  
  125.     SoundComponentDataPtr = ^SoundComponentData;
  126.  
  127.     SoundComponentData = RECORD
  128.         flags:                    LONGINT;
  129.         format:                    OSType;
  130.         numChannels:            INTEGER;
  131.         sampleSize:                INTEGER;
  132.         sampleRate:                UnsignedFixed;
  133.         sampleCount:            LONGINT;
  134.         buffer:                    ^Byte;
  135.         reserved:                LONGINT;
  136.     END;
  137.  
  138.     SoundParamBlockPtr = ^SoundParamBlock;
  139.  
  140.     SoundParamProcPtr = ProcPtr;  { FUNCTION SoundParam(VAR pb: SoundParamBlockPtr): BOOLEAN; }
  141.     SoundParamUPP = UniversalProcPtr;
  142.  
  143.     SoundParamBlock = RECORD
  144.         recordSize:                LONGINT;                                {size of this record in bytes}
  145.         desc:                    SoundComponentData;                        {description of sound buffer}
  146.         rateMultiplier:            UnsignedFixed;                            {rate multiplier to apply to sound}
  147.         leftVolume:                INTEGER;                                {volumes to apply to sound}
  148.         rightVolume:            INTEGER;
  149.         quality:                LONGINT;                                {quality to apply to sound}
  150.         filter:                    ComponentInstance;                        {filter to apply to sound}
  151.         moreRtn:                SoundParamUPP;                            {routine to call to get more data}
  152.         completionRtn:            SoundParamUPP;                            {routine to call when buffer is complete}
  153.         refCon:                    LONGINT;                                {user refcon}
  154.         result:                    INTEGER;                                {result}
  155.     END;
  156.  
  157.     SoundSource = Ptr;
  158.  
  159.     AudioInfo = RECORD
  160.         capabilitiesFlags:        LONGINT;                                {Describes device capabilities}
  161.         reserved:                LONGINT;                                {Reserved by Apple}
  162.         numVolumeSteps:            INTEGER;                                {Number of significant increments between min and max volume}
  163.     END;
  164.  
  165.     AudioInfoPtr = ^AudioInfo;
  166.  
  167. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  168. { functions for sound components}
  169. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  170. {Sound Component dispatch selectors}
  171.  
  172. CONST
  173. {these calls cannot be delegated}
  174.     kSoundComponentInitOutputDeviceSelect = 1;
  175.     kSoundComponentSetSourceSelect = 2;
  176.     kSoundComponentGetSourceSelect = 3;
  177.     kSoundComponentGetSourceDataSelect = 4;
  178.     kSoundComponentSetOutputSelect = 5;
  179.     kDelegatedSoundComponentSelectors = $0100;                    {first selector that can be delegated up the chain}
  180. {these calls can be delegated and have own range}
  181.     kSoundComponentAddSourceSelect = $101;
  182.     kSoundComponentRemoveSourceSelect = $102;
  183.     kSoundComponentGetInfoSelect = $103;
  184.     kSoundComponentSetInfoSelect = $104;
  185.     kSoundComponentStartSourceSelect = $105;
  186.     kSoundComponentStopSourceSelect = $106;
  187.     kSoundComponentPauseSourceSelect = $107;
  188.     kSoundComponentPlaySourceBufferSelect = $108;
  189.  
  190. {Audio Component selectors}
  191.     kAudioGetVolumeSelect        = 0;
  192.     kAudioSetVolumeSelect        = 1;
  193.     kAudioGetMuteSelect            = 2;
  194.     kAudioSetMuteSelect            = 3;
  195.     kAudioSetToDefaultsSelect    = 4;
  196.     kAudioGetInfoSelect            = 5;
  197.     kAudioGetBassSelect            = 6;
  198.     kAudioSetBassSelect            = 7;
  199.     kAudioGetTrebleSelect        = 8;
  200.     kAudioSetTrebleSelect        = 9;
  201.     kAudioGetOutputDeviceSelect    = 10;
  202.     kAudioMuteOnEventSelect        = 129;
  203.  
  204. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  205. { Sound Manager 3.0 utilities}
  206.  
  207. FUNCTION OpenMixerSoundComponent(outputDescription: SoundComponentDataPtr; outputFlags: LONGINT; VAR mixerComponent: ComponentInstance): OSErr;
  208.     {$IFC NOT GENERATINGCFM}
  209.     INLINE $203C, $0614, $0018, $A800;
  210.     {$ENDC}
  211. FUNCTION CloseMixerSoundComponent(ci: ComponentInstance): OSErr;
  212.     {$IFC NOT GENERATINGCFM}
  213.     INLINE $203C, $0218, $0018, $A800;
  214.     {$ENDC}
  215. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  216. { basic sound component functions}
  217. FUNCTION SoundComponentInitOutputDevice(ti: ComponentInstance; actions: LONGINT): ComponentResult;
  218.     {$IFC NOT GENERATINGCFM}
  219.     INLINE $2F3C, 4, 1, $7000, $A82A;
  220.     {$ENDC}
  221. FUNCTION SoundComponentSetSource(ti: ComponentInstance; sourceID: SoundSource; source: ComponentInstance): ComponentResult;
  222.     {$IFC NOT GENERATINGCFM}
  223.     INLINE $2F3C, 8, 2, $7000, $A82A;
  224.     {$ENDC}
  225. FUNCTION SoundComponentGetSource(ti: ComponentInstance; sourceID: SoundSource; VAR source: ComponentInstance): ComponentResult;
  226.     {$IFC NOT GENERATINGCFM}
  227.     INLINE $2F3C, 8, 3, $7000, $A82A;
  228.     {$ENDC}
  229. FUNCTION SoundComponentGetSourceData(ti: ComponentInstance; VAR sourceData: SoundComponentDataPtr): ComponentResult;
  230.     {$IFC NOT GENERATINGCFM}
  231.     INLINE $2F3C, 4, 4, $7000, $A82A;
  232.     {$ENDC}
  233. FUNCTION SoundComponentSetOutput(ti: ComponentInstance; requested: SoundComponentDataPtr; VAR actual: SoundComponentDataPtr): ComponentResult;
  234.     {$IFC NOT GENERATINGCFM}
  235.     INLINE $2F3C, 8, 5, $7000, $A82A;
  236.     {$ENDC}
  237. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  238. { junction methods for the mixer, must be called at non-interrupt level}
  239. FUNCTION SoundComponentAddSource(ti: ComponentInstance; VAR sourceID: SoundSource): ComponentResult;
  240.     {$IFC NOT GENERATINGCFM}
  241.     INLINE $2F3C, 4, $0101, $7000, $A82A;
  242.     {$ENDC}
  243. FUNCTION SoundComponentRemoveSource(ti: ComponentInstance; sourceID: SoundSource): ComponentResult;
  244.     {$IFC NOT GENERATINGCFM}
  245.     INLINE $2F3C, 4, $0102, $7000, $A82A;
  246.     {$ENDC}
  247. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  248. { info methods}
  249. FUNCTION SoundComponentGetInfo(ti: ComponentInstance; sourceID: SoundSource; selector: OSType; infoPtr: UNIV Ptr): ComponentResult;
  250.     {$IFC NOT GENERATINGCFM}
  251.     INLINE $2F3C, 12, $0103, $7000, $A82A;
  252.     {$ENDC}
  253. FUNCTION SoundComponentSetInfo(ti: ComponentInstance; sourceID: SoundSource; selector: OSType; infoPtr: UNIV Ptr): ComponentResult;
  254.     {$IFC NOT GENERATINGCFM}
  255.     INLINE $2F3C, 12, $0104, $7000, $A82A;
  256.     {$ENDC}
  257. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  258. { control methods}
  259. FUNCTION SoundComponentStartSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $2F3C, 6, $0105, $7000, $A82A;
  262.     {$ENDC}
  263. FUNCTION SoundComponentStopSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $2F3C, 6, $0106, $7000, $A82A;
  266.     {$ENDC}
  267. FUNCTION SoundComponentPauseSource(ti: ComponentInstance; count: INTEGER; VAR sources: SoundSource): ComponentResult;
  268.     {$IFC NOT GENERATINGCFM}
  269.     INLINE $2F3C, 6, $0107, $7000, $A82A;
  270.     {$ENDC}
  271. FUNCTION SoundComponentPlaySourceBuffer(ti: ComponentInstance; sourceID: SoundSource; pb: SoundParamBlockPtr; actions: LONGINT): ComponentResult;
  272.     {$IFC NOT GENERATINGCFM}
  273.     INLINE $2F3C, 12, $0108, $7000, $A82A;
  274.     {$ENDC}
  275. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  276. { interface for Audio Components}
  277. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  278. {Volume is described as a value between 0 and 1, with 0 indicating minimum
  279.   volume and 1 indicating maximum volume; if the device doesn't support
  280.   software control of volume, then a value of unimpErr is returned, indicating
  281.   that these functions are not supported by the device}
  282. FUNCTION AudioGetVolume(ac: ComponentInstance; whichChannel: INTEGER; VAR volume: ShortFixed): ComponentResult;
  283.     {$IFC NOT GENERATINGCFM}
  284.     INLINE $2F3C, 6, 0, $7000, $A82A;
  285.     {$ENDC}
  286. FUNCTION AudioSetVolume(ac: ComponentInstance; whichChannel: INTEGER; volume: ShortFixed): ComponentResult;
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $2F3C, 4, 1, $7000, $A82A;
  289.     {$ENDC}
  290. {If the device doesn't support software control of mute, then a value of unimpErr is}
  291. {returned, indicating that these functions are not supported by the device}
  292. FUNCTION AudioGetMute(ac: ComponentInstance; whichChannel: INTEGER; VAR mute: INTEGER): ComponentResult;
  293.     {$IFC NOT GENERATINGCFM}
  294.     INLINE $2F3C, 6, 2, $7000, $A82A;
  295.     {$ENDC}
  296. FUNCTION AudioSetMute(ac: ComponentInstance; whichChannel: INTEGER; mute: INTEGER): ComponentResult;
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $2F3C, 4, 3, $7000, $A82A;
  299.     {$ENDC}
  300. {AudioSetToDefaults causes the associated device to reset its volume and mute values}
  301. {(and perhaps other characteristics, e.g. attenuation) to "factory default" settings}
  302. FUNCTION AudioSetToDefaults(ac: ComponentInstance): ComponentResult;
  303.     {$IFC NOT GENERATINGCFM}
  304.     INLINE $2F3C, 0, 4, $7000, $A82A;
  305.     {$ENDC}
  306. {This routine is required; it must be implemented by all audio components}
  307. FUNCTION AudioGetInfo(ac: ComponentInstance; info: AudioInfoPtr): ComponentResult;
  308.     {$IFC NOT GENERATINGCFM}
  309.     INLINE $2F3C, 4, 5, $7000, $A82A;
  310.     {$ENDC}
  311. FUNCTION AudioGetBass(ac: ComponentInstance; whichChannel: INTEGER; VAR bass: INTEGER): ComponentResult;
  312.     {$IFC NOT GENERATINGCFM}
  313.     INLINE $2F3C, 6, 6, $7000, $A82A;
  314.     {$ENDC}
  315. FUNCTION AudioSetBass(ac: ComponentInstance; whichChannel: INTEGER; bass: INTEGER): ComponentResult;
  316.     {$IFC NOT GENERATINGCFM}
  317.     INLINE $2F3C, 4, 7, $7000, $A82A;
  318.     {$ENDC}
  319. FUNCTION AudioGetTreble(ac: ComponentInstance; whichChannel: INTEGER; VAR Treble: INTEGER): ComponentResult;
  320.     {$IFC NOT GENERATINGCFM}
  321.     INLINE $2F3C, 6, 8, $7000, $A82A;
  322.     {$ENDC}
  323. FUNCTION AudioSetTreble(ac: ComponentInstance; whichChannel: INTEGER; Treble: INTEGER): ComponentResult;
  324.     {$IFC NOT GENERATINGCFM}
  325.     INLINE $2F3C, 4, 9, $7000, $A82A;
  326.     {$ENDC}
  327. FUNCTION AudioGetOutputDevice(ac: ComponentInstance; VAR outputDevice: Component): ComponentResult;
  328.     {$IFC NOT GENERATINGCFM}
  329.     INLINE $2F3C, 4, 10, $7000, $A82A;
  330.     {$ENDC}
  331. {This is routine is private to the AudioVision component.  It enables the watching of the mute key.}
  332. FUNCTION AudioMuteOnEvent(ac: ComponentInstance; muteOnEvent: INTEGER): ComponentResult;
  333.     {$IFC NOT GENERATINGCFM}
  334.     INLINE $2F3C, 2, 129, $7000, $A82A;
  335.     {$ENDC}
  336. CONST
  337.     uppSoundParamProcInfo = $000000D0; { FUNCTION (4 byte param): 1 byte result; }
  338.  
  339. FUNCTION NewSoundParamProc(userRoutine: SoundParamProcPtr): SoundParamUPP;
  340.     {$IFC NOT GENERATINGCFM }
  341.     INLINE $2E9F;
  342.     {$ENDC}
  343.  
  344. FUNCTION CallSoundParamProc(VAR pb: SoundParamBlockPtr; userRoutine: SoundParamUPP): BOOLEAN;
  345.     {$IFC NOT GENERATINGCFM}
  346.     INLINE $205F, $4E90;
  347.     {$ENDC}
  348.  
  349. { $ALIGN RESET}
  350. { $POP}
  351.  
  352. {$ENDC} {__SOUNDCOMPONENTS__}
  353.  
  354.  IMPLEMENTATION
  355.  END.
  356.  
  357.